import request from '@/utils/request'
import  {getUserId} from '@/utils/auth'
var path = "/routing"
export default {
    findByIdRouting(userId){
        return request({
            url: `${path}/findAll?userId=${userId}`,
            method: "get"
        })
    },


    /**
     *  分页查询
     * @param { } data 
     * @returns 
     */
    list(data) {
        return request({
            url: `${path}/list`,
            method: "get",
            params: data
        })
    },

    /**
     * 
     * @returns  全部查询
     */
    async findAll() {
        return request({
            url: `${path}/findAll`,
            method: "get"
        })
    },


    info(id) {
        return request({
            url: `${path}/info/${id}`,
            method: 'get',
        })
    },
    /**
   *  修改 和 添加
   * @param {修改的对象数据封装} data 
   * @returns 
   */
    updateAdd(data) {
        return request({
            url: `${path}/${!data.id ? "save" : "update"}`,
            method: "post",
            data
        })
    },
    /**
 *  删除的ids
 * @param {删除} data 
 * @returns 
 */
    delete(data) {
        return request({
            url: `${path}/delete`,
            method: "post",
            data
        })
    },


    purview(routId){
        return request({
            url: `${path}/purview?routId=${routId}&userId=${getUserId()}`,
            method: "get",
        })
    }

}